﻿using System.Collections.Generic;
using FacebookWrapper.ObjectModel;

namespace Desktop_Facebook
{
	internal class CSVMessagesSerializer : AbstractCSVSerializer
	{
		public List<Message> MessagesToSave	{ get; set; }

		protected override List<List<string>> GetRows()
		{
			List<List<string>> rows = new List<List<string>>();

			List<string> header = new List<string>();
			header.Add("id");
			header.Add("time");
			header.Add("from");
			header.Add("text");

			rows.Add(header);
			foreach (Message currentMessage in MessagesToSave)
			{
				List<string> row = new List<string>();
				row.Add(currentMessage.Id.ToString());
				row.Add(currentMessage.CreatedTime.ToString());
				row.Add(currentMessage.From.Name.ToString());
				row.Add(RemoveSeperatorsFromString(currentMessage.Text.ToString()));
				rows.Add(row);
			}

			return rows;
		}
	}
}
